<?php
/**
 * 博主最新资讯
 * limit 
 * queryType (1:最新资讯 时间倒序)
 * blognewcontroller.php
 * Create on 2015-04-18
 * Create by yuebin
 */
namespace haibao\cms\business\control\pc\channel\blog;

use haibao\cms\business\control\PublicController as PublicControllerBusiness;

class BlogNewController extends \haibao\cms\business\control\pc\channel\ChannelController{
	
	const QUERY_TYPE_NEW_BLOG = 1;
	public function __construct($updateTime = null,$controlId,$isPublish){
		parent::__construct($updateTime,$controlId,$isPublish);
	}
	
	
	/**
	 * 获取模版内容
	 * @param : String $content
	 */
	public function displayTemplateHtml(){
	
		$controlData = $this->getParameter(self::$CONTROL_DATA);
		$content = $this->getParameter(self::$CONTROL_CONTENT);
		$blogArr = array();
		if($controlData['manual']){

			$category = self::getBlogCategory();
			$queryType = $controlData['manual']['queryType'];
			$currentPage = $this->getParameter(self::$CURRENTPAGE)?$this->getParameter(self::$CURRENTPAGE):1;
			if($queryType == self::QUERY_TYPE_NEW_BLOG){
				$blogArr = PublicControllerBusiness::getNewBlogList($currentPage);
			}
			foreach($blogArr as $key=>$blog){
				$blogArr[$key]['url'] = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_BOZHU).'/blog/'.$blog['blogid'].'.htm';
				$blogArr[$key]['dateline'] = $this->formatDate(date('Y-m-d H:i:s',$blogArr[$key]['dateline']));
				$blogArr[$key]['catename'] = $category[$blog['cate_id']]['name'];
				$blogArr[$key]['cateurl'] = $category[$blog['cate_id']]['url'];
				$blogArr[$key]['usercenter'] = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_BOZHU).'/user/'.$blog['uid'].'/';
				
			}
		}
		$this->assign('blogArr',array_values($blogArr));
		$this->assign('attentionType',\haibao\www\model\data\Favorite::ATTENTION_TYPE_BLOGGER);
		$path = $this->generateHtmlPath(__CLASS__);
		$this->generateHtml($path,$content);
		$content = $this->getHtml($path);
		$content = $this->replaceCDNLink($content);
		return $content;
	}
}